/*
 * CommandeTourner.cpp
 *
 *  Created on: 22 déc. 2012
 *      Author: aboursie - potier
 */

#include "CommandeTourner.h"

bool CommandeTourner::initialiserArguments(vector<string> args) {
	bool flag = false;
	if (args.size() == 1) {
		direction = args[0].c_str();
		flag = true;
	}else{
		pile.pop();
	}
	return flag;
}

void CommandeTourner::execute() {
	try{
		robot->tourner(direction);
	}catch (EtatRobot::BadAction){
		pile.pop();
	}
}

void CommandeTourner::desexecute() {
	robot->tourner(last_direction);
	pile.pop();
}

Commande* CommandeTourner::constructeurVirtuel() {
	CommandeTourner* tmp = new CommandeTourner(robot);
	tmp->direction = direction;
	if (pile.size() == 0) {
		tmp->last_direction = "NORD";
	} else {
		tmp->last_direction = direction;
	}
	pile.push(tmp);
	return tmp;
}
